# +----------------------------------------------------------------------
# | ChatWork
# +----------------------------------------------------------------------
# | 这不是一个自由软件,您只能在不用于商业目的的前提下对程序代码进行修改和使用。
# | 任何企业和个人不允许对程序代码以任何形式任何目的再发布,商业使用请获取授权。
# +----------------------------------------------------------------------
# | Author: ChatWork Team <2474369941@qq.com>
# +----------------------------------------------------------------------
from typing import Union
from fastapi import Query
from pydantic import BaseModel, Field


class RobotTeamedSearchIn(BaseModel):
    """ 团队成员搜索参数 """
    ap_code: str = Query(..., min_length=1, max_length=32, description="智能体编号")
    keyword: Union[str, int, None] = Query(max_length=20, default=None, description="关键词")


class RobotTeamedAddIn(BaseModel):
    """ 团队成员新增参数 """
    ap_code: str = Field(..., min_length=1, max_length=32, description="智能体编号")
    user_sn: str = Field(..., min_length=1, max_length=20, description="用户编号")
    power: int = Field(..., ge=1, le=3, description="权力: [1=查看者, 2=编辑者, 3-管理者]")

    class Config:
        json_schema_extra = {
            "example": {
                "ap_code": "pdr4ah4nbs0u5hti",
                "user_sn": "82964701",
                "power": 1
            }
        }


class RobotTeamedEditIn(BaseModel):
    """ 团队成员编辑参数 """
    id: int = Field(..., ge=1, description="ID")
    power: int = Field(..., ge=1, le=3, description="权力: [1=查看者, 2=编辑者, 3-管理者]")

    class Config:
        json_schema_extra = {
            "example": {
                "id": 1,
                "power": 1
            }
        }


class RobotTeamedDeleteIn(BaseModel):
    """ 团队成员删除参数 """
    id: int = Field(..., gt=0, description="ID")

    class Config:
        json_schema_extra = {
            "example": {
                "id": 1
            }
        }


class RobotTeamedExitsIn(BaseModel):
    """ 退出当前团队参数 """
    ap_code: str = Field(..., min_length=1, max_length=32, description="智能体编号")

    class Config:
        json_schema_extra = {
            "example": {
                "ap_code": "RuMiVZPMoc3ih5aj"
            }
        }


"""--------------- Separator ---------------"""


class RobotTeamedUserVo(BaseModel):
    """ 团队用户查询VO """
    sn: str = Field(description="用户编号")
    avatar: str = Field(description="用户头像")
    nickname: str = Field(description="用户昵称")

    class Config:
        json_schema_extra = {
            "example": {
                "sn": "82964701",
                "avatar": "http://0.0.0.0:8200/static/images/default_avatar.png",
                "nickname": "82964701"
            }
        }


class RobotTeamedListVo(BaseModel):
    """ 团队成员列表VO """
    id: int = Field(description="ID")
    user_sn: str = Field(description="用户编号")
    user_avatar: str = Field(description="用户头像")
    user_nickname: str = Field(description="用户昵称")
    power: int = Field(description="权力: [1=查看者, 2=编辑者, 3-管理者]")
    create_time: str = Field(description="创建时间")
    update_time: str = Field(description="更新时间")

    class Config:
        json_schema_extra = {
            "example": {
                "id": 0,
                "user_sn": "52778960",
                "user_avatar": "http://0.0.0.0:8200/static/images/default_avatar.png",
                "user_nickname": "52778960",
                "power": 4,
                "create_time": "2025-01-21 22:42:43",
                "update_time": "2025-01-21 22:42:43"
            }
        }
